<?php
if (!isset($_SESSION)) {
    session_start();
}
include 'header.php';?>
    <div class="body">
        <div class="article">
            <div class="header">
                <h3>Thông tin giỏ hàng</h3>
            </div>
            <div class="extra-wrap">
                <style>
                    table, th, td {
                        border: 1px solid black;
                        border-collapse: collapse;
                        padding: 5px;
                    }
                </style>
                <form method="post" action="updateCart.php">
                    <table>
                        <thead>
                        <tr>
                            <th>Mã sp</th>
                            <th>Tên sp</th>
                            <th>Đơn giá</th>
                            <th>Số lượng</th>
                            <th>Công cụ</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php
                        if (!empty($_SESSION['cart'])) {
                            foreach ($_SESSION['cart'] as $k => $v) {
                                ?>
                                <tr>
                                    <td><?php echo $k; ?></td>
                                    <td><?php echo $v['name']; ?></td>
                                    <td><?php echo $v['price']; ?></td>
                                    <td><input type="number" name="qty[]" min=1
                                               value="<?php echo $v['qty']; ?>"/></td>
                                    <td><a href="deleteCart.php?ime=<?php echo $k ?>">Xóa</a></td>
                                </tr>
                            <?php
                            }
                        } else {
                            echo '<tr><td colspan="5">Ban khong co mon hang nao trong gio hang</td></tr>';
                        }
                        ?>
                        </tbody>
                    </table>
                    <br>

                    <?php if (!empty($_SESSION['cart'])) { ?>
                        <input type="submit" value="Cập nhật"/>
                        <input type="button" value="Kế tiếp"
                               onclick="window.location.href='checkIn.php'"/>
                    <?php } ?>
                </form>
            </div>
        </div>
    </div>
<?php
include 'footer.php';?>